<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
<head>
  <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type" />
  <link rel="stylesheet" type="text/css" href="style.css" />
  <title>SOCI - beyond</title>
</head>

<body>
<p class="banner">SOCI - The C++ Database Access Library</p>

<h2>Beyond SOCI</h2>

<p>As the original name of the library (Simple Oracle Call Interface)
clearly stated, SOCI is intended to be a <i>simple</i> library, targetting the
majority of needs in regular C++ application. We do not claim that
<i>everything</i> can be done with SOCI and it was never the intent of the
library. What is important, though, is that the simplicity of the
library does <i>not</i> prevent the
client applications from reaching into the low-level specifics of each
database backend in order to achieve special configuration or
performance goals.</p>

<p>Most of the SOCI classes have the <code>getBackEnd</code> method,
which
returns the pointer to the actual backend object that implements the
given functionality. The knowledge of the actual backend allows the
client application to get access to all low-level details that are
involved.</p>

<pre class="example">
blob b(sql);

oracle_session_back_end * sessionBackEnd = static_cast&lt;oracle_session_back_end *&gt;(sql.get_back_end());
oracle_blob_back_end * blobBackEnd = static_cast&lt;oracle_blob_back_end *&gt;(b.get_back_end());

OCILobDisableBuffering(sessionBackEnd-&gt;svchp_, sessionBackEnd-&gt;errhp_, blobBackEnd-&gt;lobp_);
</pre>

<p>The above code creates the <code>blob</code> object and uses two calls
to the <code>get_back_end</code> function (on both the <code>session</code>
and the <code>blob</code> objects) to get access to the actual backend
objects. Assuming that it is the <code>"oracle"</code> backend which
is in use, the downcasts allow to access all relevant low-level handles
and use them in the call
to the <code>OCILobDisableBuffering</code> function. This way, the
BLOB handle was configured in a way that the SOCI library alone would
not allow.</p>

<pre class="example">
rowid rid(sql); // sql is a session object
sql &lt;&lt; "select oid from mytable where id = 7", into(rid);

postgresql_rowid_back_end * rbe = static_cast&lt;postgresql_rowid_back_end *&gt;(rid.get_back_end());

unsigned long oid = rbe-&gt;value_;
</pre>

<p>The above example retrieves the <code>rowid</code> ("something" that
identifies the
row in the table) from the table and uses the <code>get_back_end</code>
function to
extract the actual object that implements this functionality. Assuming
that it is the <code>"postgresql"</code> backend which is in use, the
downcast is
performed to use the <code>postgresql_rowid_back_end</code> interface to
get the actual
OID value that is a physical, low-level implementation of row
identifier on PostgreSQL databases.</p>

<p>In order for any of the above to compile, you have to explicitly <code>#include</code>
the appropriate backend's header file.</p>

<p>Please see the header file related to the given backend to learn what
low-level handles and descriptors are available.</p>

<table class="foot-links" border="0" cellpadding="2" cellspacing="2">
  <tr>
    <td class="foot-link-left">
      <a href="statements.html">Previous (Interfaces)</a>
    </td>
    <td class="foot-link-right">
      <a href="reference.html">Next (Client reference)</a>
    </td>
  </tr>
</table>

<p class="copyright">Copyright &copy; 2004-2006 Maciej Sobczak, Stephen Hutton</p>
</body>
</html>
